<?php

namespace App\Http\Requests\Logic\Attendance;

use Illuminate\Support\Facades\Auth;
use Illuminate\Foundation\Http\FormRequest;

class ReportOfYear extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
		$user = Auth::user();
		// 判断是否有查看考勤报表的权限
		if ($user->hasPermission('attendance_report')) {
			return true;
		}
		return false;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
        	'project_id' => 'required',
			'year' => 'nullable'
        ];
    }

	/**
	 * Define validation error messages
	 *
	 * Date: 2018/6/19
	 * @author George
	 * @return array
	 */
	public function messages()
	{
		return [
			'project_id.required' => '请选择项目'
		];
    }
}
